import 'package:flutter/material.dart';
import 'package:twitter_app/themes/dark_theme.dart';
import 'package:twitter_app/themes/light_theme.dart';

class ThemeProvider with ChangeNotifier {
  // 初始化主题数据
  ThemeData _themeData = lightTheme;

  // 获取当前主题数据
  ThemeData get themeData => _themeData;
  // 判断当前主题是否为暗黑模式
  bool get isDarkMode => _themeData == darkTheme;
  // 设置主题
  set themeData(ThemeData themeData) {
    _themeData = themeData;
    // 通知监听器
    notifyListeners();
  }

  // 切换主题
  void toggleTheme() {
    _themeData == lightTheme ? themeData = darkTheme : themeData = lightTheme;
  }
}
